****
** Replication File:
**
** Christian Nationalism and Political Violence: 
** Victimhood, White Identity, Conspiracy and 
** Support for the Capitol Attacks
**
** Miles T. Armaly, David T. Buckley, and Adam M. Enders
****

set more off

* Set working directory

* Open data
use "Raw Data, Feb 2021.dta"

********************************************************************************

****
** Recode and create variables
****

* Perceived victimhood

alpha q2_1-q2_4 q3_1-q3_4, gen(victimhood) reverse(q2_1-q2_4 q3_1-q3_4)


* Conspiracy thinking
foreach v of var q9_1-q9_4{ 
	replace `v' = (`v' * -1) + 6
}

alpha q9_1-q9_4, gen(conthink)


* Trust in government
gen trustgov = q11
replace trustgov = . if q11 > 5


* QAnon
gen heardof = q12
recode heardof (2=0) (3=.)

gen supportq = (q13 * -1) + 6


* Partisanship
gen pid = .
replace pid = 1 if q23 == 1
replace pid = 2 if q23 == 2
replace pid = 3 if q24 == 2
replace pid = 4 if q24 == 3 | q24 == 4
replace pid = 5 if q24 == 1
replace pid = 6 if q22 == 2
replace pid = 7 if q22 == 1

gen pidstrength = abs(pid - 4) + 1

gen rep = .
replace rep = 1 if pid > 4 & pid < .
replace rep = 0 if pid < 5


* Ideology
gen ideo = q25
replace ideo = . if q25 > 7

gen ideostrength = abs(ideo - 4) + 1

gen conserv = .
replace conserv = 1 if ideo > 4 & ideo < .
replace conserv = 0 if ideo < 5


* Interest in politics
gen interest = (q26 * -1) + 5


* Capitol riots and violence
gen justified = (q30_1 * -1) + 6

foreach v of var q30_2-q30_4{ 
	replace `v' = (`v' * -1) + 6
}

alpha q30_2-q30_4, gen(violence)


* Generate authoritarianism
foreach v of var q16_1-q16_3{ 
	replace `v' = (`v' * -1) + 6
}

alpha q16_1-q16_3, gen(authoritarian)


* Generate fraud attitudes
gen collusion = (q29_3 * -1) + 6


* Region
gen south = 0
replace south = 1 if q32 == 3


* Gender
gen female = 0
replace female = 1 if q33 == 2


* Latinx
gen latinx = 0
replace latinx = 1 if q34 == 1


* Race
gen white = 0
replace white = 1 if q35_5 == 1

gen black = 0
replace black = 1 if q35_3 == 1


* Education
gen edu = q36


* Religious denominations
gen evangelical = 0
replace evangelical = 1 if q38 == 1 & q37==1

gen evangelicalbroad = 0
replace evangelicalbroad = 1 if q38 == 1

gen protestant = 0
replace protestant = 1 if q38 == 2 & q37==1

gen catholic = 0
replace catholic = 1 if q37 == 2

gen otherchristian = 0 
replace otherchristian = 1 if q37 == 3  
replace otherchristian = 1 if q37 == 4

gen otherreligion = 0
replace otherreligion = 1 if q37 >=5 & q37 <= 8
replace otherreligion = 1 if q37 ==11 

gen nones = 0
replace nones = 1 if q37 ==9
replace nones = 1 if q37 ==10
replace nones = 1 if q37 ==12


* Religiosity
gen attend = (q39 * -1) + 6


* Income
gen income = q41
replace income = . if q41 == 6


* Christian nationalism
foreach v of var q42_1-q42_2 q42_4-q42_6{ 
	replace `v' = (`v' * -1) + 6
}

factor q42_1-q42_6, ipf
alpha q42_1-q42_6, gen(nationalism)


* White identity
foreach v of var q43-q46{ 
	replace `v' = (`v' * -1) + 6
}

alpha q43-q46, gen(whiteidentity)


* Trump thermometer
gen trumpft = q27_3


* Rescale to range from 0 (min) to 1 (max)
foreach v of var whiteidentity nationalism income attend ///
	edu violence justified supportq interest ideo pid ideostrength ///
	pidstrength victimhood age{ 
	su `v', meanonly 
	gen `v'2 = (`v' - r(min))/(r(max) - r(min)) 
}

********************************************************************************

****
** Table A1 (appendix)
****

sum age, detail
tab edu
tab female
sum income, detail
tab white
tab black
tab latinx

drop if white == 0

saveold "Clean Data, Feb 2021 2.dta", version(12) replace

********************************************************************************

****
** Correlations reported in 
** Data section
****

pwcorr justified pid ideo trumpft, sig

pwcorr nationalism justified violence, sig
pwcorr whiteidentity justified violence, sig
pwcorr victimhood justified violence, sig
pwcorr supportq justified violence, sig

pwcorr nationalism whiteidentity victimhood, sig

pwcorr pid evangelical nationalism whiteidentity victimhood ideo, sig

********************************************************************************

****
** Additive models for Table 1 
** and estimates for Figure 2
****

****
** Capitol riots justified
****

* Model 1
reg justified pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south if white == 1
est store mod1

* Model 2
reg justified victimhood2 whiteidentity2 nationalism2 pid2 ideo2  ///
	evangelical protestant catholic otherchristian otherreligion attend2 edu2 age2 ///
	latinx female south 
est store mod2
margins, at(nationalism2=(0(.1)1))
matrix list r(table)
matrix m0 = r(at)
matrix  m11 = m0[1..., "nationalism2"]
matrix m1 = r(table)
matrix  m12 = m1["b", 1...]'
matrix m13 = m1["ll".."ul",1...]'
matrix first = m11,m12,m13

margins, at(whiteidentity2=(0(.1)1))
matrix m2 = r(at)
matrix  m21 = m2[1..., "whiteidentity2"]
matrix m3 = r(table)
matrix m31 = m3["b", 1...]'
matrix m32 = m3["ll".."ul",1...]'
matrix second = m21,m31,m32

margins, at(victimhood2=(0(0.1)1))
matrix m4 = r(at)
matrix  m41 = m4[1..., "victimhood2"]
matrix m5 = r(table)
matrix m51 = m5["b", 1...]'
matrix m52 = m5["ll".."ul",1...]'
matrix third = m41,m51,m52

* Model 3
reg justified victimhood2 whiteidentity2 nationalism2 supportq2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south 
est store mod3

margins, at(supportq2=(0(.2)1))
matrix m6 = r(at)
matrix  m61 = m6[1..., "supportq2"]
matrix m7 = r(table)
matrix m71 = m7["b", 1...]'
matrix m72 = m7["ll".."ul",1...]'
matrix fourth = m61,m71,m72

* Save predictions
matrix rownames first = 1
matrix rownames second = 2
matrix rownames third = 3
matrix rownames fourth = 4
matrix colnames first = scale estimate lower upper

matrix RESULTS = first \ second \ third \ fourth

* Save predictions
preserve
matsave RESULTS, dropall
rename _rowname order
saveold "Justified Predictions.dta", version(12) replace
erase RESULTS.dta
clear
restore	
	
****
** Acceptance of violence
****

* Model 4
reg violence pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south if white == 1
est store mod4

* Model 5
reg violence victimhood2 whiteidentity2 nationalism2 pid2 ideo2  ///
	evangelical protestant catholic otherchristian otherreligion attend2 edu2 age2 ///
	latinx female south 
est store mod5

margins, at(nationalism2=(0(.1)1))
matrix list r(table)
matrix m0 = r(at)
matrix  m11 = m0[1..., "nationalism2"]
matrix m1 = r(table)
matrix  m12 = m1["b", 1...]'
matrix m13 = m1["ll".."ul",1...]'
matrix first = m11,m12,m13

margins, at(whiteidentity2=(0(.1)1))
matrix m2 = r(at)
matrix  m21 = m2[1..., "whiteidentity2"]
matrix m3 = r(table)
matrix m31 = m3["b", 1...]'
matrix m32 = m3["ll".."ul",1...]'
matrix second = m21,m31,m32

margins, at(victimhood2=(0(.1)1))
matrix m4 = r(at)
matrix  m41 = m4[1..., "victimhood2"]
matrix m5 = r(table)
matrix m51 = m5["b", 1...]'
matrix m52 = m5["ll".."ul",1...]'
matrix third = m41,m51,m52		
	
* Model 6	
reg violence victimhood2 whiteidentity2 nationalism2 supportq2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 ///
	edu2 age2 latinx female south 
est store mod6	

margins, at(supportq2=(0(.2)1))
matrix m6 = r(at)
matrix  m61 = m6[1..., "supportq2"]
matrix m7 = r(table)
matrix m71 = m7["b", 1...]'
matrix m72 = m7["ll".."ul",1...]'
matrix fourth = m61,m71,m72

* Save predictions
matrix rownames first = 1
matrix rownames second = 2
matrix rownames third = 3
matrix rownames fourth = 4
matrix colnames first = scale estimate lower upper

matrix RESULTS = first \ second \ third \ fourth

preserve
matsave RESULTS, dropall
rename _rowname order
saveold "Violence Predictions.dta", version(12) replace
erase RESULTS.dta
clear
restore

* Save model estimates for Table 1
esttab mod1 mod2 mod3 mod4 mod5 mod6 using "Table 1.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)
	
********************************************************************************

****
** Interactive models for Table 2 (Table A2 in appendix)
** and estimates for Figure 3
****	

****
** Capitol riots justified
****
	
* Model 1	
reg justified c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south
est store mod7

margins, dydx(whiteidentity2) at(nationalism2=(0(.1)1))
matrix list r(table)
matrix m0 = r(at)
matrix m11 = m0[1..., "nationalism2"]
matrix m1 = r(table)
matrix m12 = m1["b", 1...]'
matrix m13 = m1["ll".."ul",1...]'
matrix first = m11,m12,m13

margins, dydx(victimhood2) at(nationalism2=(0(.1)1))
matrix m2 = r(at)
matrix m21 = m2[1..., "nationalism2"]
matrix m3 = r(table)
matrix m31 = m3["b", 1...]'
matrix m32 = m3["ll".."ul",1...]'
matrix second = m21,m31,m32	

* Model 2
reg justified victimhood2 whiteidentity2 c.nationalism2##c.supportq2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 ///
	edu2 age2 latinx female south 
est store mod8

margins, dydx(nationalism2) at(supportq2=(0(0.25)1))	
matrix list r(table)
matrix m4 = r(at)
matrix m51 = m4[1..., "supportq2"]
matrix m5 = r(table)
matrix m52 = m5["b", 1...]'
matrix m53 = m5["ll".."ul",1...]'
matrix third = m51,m52,m53

* Save marginal effects
matrix rownames first = 1
matrix rownames second = 2
matrix rownames third = 3
matrix colnames first = scale estimate lower upper

matrix RESULTS = first \ second \ third

preserve
matsave RESULTS, dropall
rename _rowname order
saveold "Justified Marginal Effects.dta", version(12) replace
erase RESULTS.dta
clear
restore
		
* Model 3
reg violence c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south
est store mod9

margins, dydx(whiteidentity2) at(nationalism2=(0(.1)1))
matrix list r(table)
matrix m0 = r(at)
matrix  m11 = m0[1..., "nationalism2"]
matrix m1 = r(table)
matrix  m12 = m1["b", 1...]'
matrix m13 = m1["ll".."ul",1...]'
matrix first = m11,m12,m13

margins, dydx(victimhood2) at(nationalism2=(0(.1)1))
matrix m2 = r(at)
matrix  m21 = m2[1..., "nationalism2"]
matrix m3 = r(table)
matrix m31 = m3["b", 1...]'
matrix m32 = m3["ll".."ul",1...]'
matrix second = m21,m31,m32

* Model 4	
reg violence victimhood2 whiteidentity2 c.nationalism2##c.supportq2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 ///
	edu2 age2 latinx female south 
est store mod10	

margins, dydx(nationalism2) at(supportq2=(0(0.25)1))	
matrix list r(table)
matrix m4 = r(at)
matrix m51 = m4[1..., "supportq2"]
matrix m5 = r(table)
matrix m52 = m5["b", 1...]'
matrix m53 = m5["ll".."ul",1...]'
matrix third = m51,m52,m53

* Save marginal effects
matrix rownames first = 1
matrix rownames second = 2
matrix rownames third = 3
matrix colnames first = scale estimate lower upper

matrix RESULTS = first \ second \ third

preserve
matsave RESULTS, dropall
rename _rowname order
saveold "Violence Marginal Effects.dta", version(12) replace
erase RESULTS.dta
clear
restore

* Save model estimates for Table 2
esttab mod7 mod8 mod9 mod10 using "Table 2.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)				
	
********************************************************************************

****
** Table A3 (appendix)
****		

* Captiol riot
tobit justified pid2 ideo2 evangelical protestant catholic otherchristian ///
	otherreligion attend2 edu2 age2 latinx female south
est store mod11	
	
tobit justified nationalism2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south	
est store mod12	
	
tobit justified supportq2 nationalism2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south	
est store mod13	
	
* Violence
tobit violence pid2 ideo2 evangelical protestant catholic otherchristian ///
	otherreligion attend2 edu2 age2 latinx female south
est store mod14	
	
tobit violence nationalism2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south	
est store mod15	
	
tobit violence supportq2 nationalism2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south	
est store mod16
	
esttab mod11 mod12 mod13 mod14 mod15 mod16 using "Table A3.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)
	
********************************************************************************

****
** Table A4 (appendix)
****	
	
* Justified
tobit justified c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south
est store mod17

tobit justified c.nationalism2##c.supportq2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south
est store mod18	

* Violence
tobit violence c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south
est store mod19	

tobit violence c.nationalism2##c.supportq2 victimhood2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion ///
	attend2 edu2 age2 latinx female south
est store mod20
	
esttab mod17 mod18 mod19 mod20 using "Table A4.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: Tobit coefficients with standard errors in parentheses)	
	
********************************************************************************

****
** Tables A5–A10
****	

* Break all variables into thirds
xtile violence3 = violence, nquantiles(3)
xtile whiteidentity3 = whiteidentity, nquantiles(3)
xtile victimhood3 = victimhood, nquantiles(3)
xtile nationalism3 = nationalism, nquantiles(3)
gen supportq3 = .
replace supportq3 = 1 if supportq == 1
replace supportq3 = 1 if supportq == 2
replace supportq3 = 2 if supportq == 3
replace supportq3 = 3 if supportq == 4
replace supportq3 = 3 if supportq == 5

gen justified3 = .
replace justified3 = 1 if justified == 1
replace justified3 = 1 if justified == 2
replace justified3 = 2 if justified == 3
replace justified3 = 3 if justified == 4
replace justified3 = 3 if justified == 5

* Cross-tabulation tables
table justified3 victimhood3 nationalism3, col
table justified3 whiteidentity3 nationalism3, col
table justified3 supportq3 nationalism3, col

table violence3 victimhood3 nationalism3, col
table violence3 whiteidentity3 nationalism3, col
table violence3 supportq3 nationalism3, col	
	
********************************************************************************

****
** Quantities for Figure A2 (stored in 
** "CN by Affiliation.csv" and 
** "CN by Political Orientation.csv")
****	

mean nationalism if evangelical == 1
mean nationalism if protestant == 1
mean nationalism if catholic == 1
mean nationalism if otherchristian == 1
mean nationalism if otherreligion == 1
mean nationalism if none == 1

mean nationalism if rep == 1
mean nationalism if rep == 0
mean nationalism if pid == 4
mean nationalism if conserv == 1
mean nationalism if conserv == 0
mean nationalism if ideo == 4
	
********************************************************************************

****
** Table A11
****	

reg justified victimhood2 nationalism2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south if heardof == 0
est store mod1	
	
reg justified c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south if heardof == 0
est store mod2
	
reg violence victimhood2 nationalism2 whiteidentity2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south if heardof == 0		
est store mod3	
	
reg violence c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south if heardof == 0
est store mod4	
	
esttab mod1 mod2 mod3 mod4 using "Table A11.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)	
	
********************************************************************************

****
** Table A12
****
	
reg violence c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south authoritarian collusion
est store mod1	

reg justified c.victimhood2##c.nationalism2 c.whiteidentity2##c.nationalism2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south authoritarian collusion
est store mod2	

reg violence c.supportq##c.nationalism2 whiteidentity2 victimhood2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south authoritarian collusion
est store mod3	

reg justified c.supportq##c.nationalism2 whiteidentity2 victimhood2 ///
	pid2 ideo2 evangelical protestant catholic otherchristian otherreligion attend2 edu2 ///
	age2 latinx female south authoritarian collusion
est store mod4	
	
esttab mod1 mod2 mod3 mod4 using "Table A12.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)
	
